#include <iostream>
#include "DeviceFsk.h"
#include "tool.h"


DeviceFsk::DeviceFsk(string data1,string data2)
{
  this->gs240_Status = NULL;
  this->gs241_Status = NULL;
  this->gs361_Status = NULL;
  this->gs870_Status = NULL;
  handlerDevStatus(data1,data2);
}


void DeviceFsk::handlerDevStatus(string data_str1,string data_str2){

    if(data_str1.empty()||data_str2.empty()){
      this->result_err = ERR_NULL_STRING;
      return;
    }
    
    if(data_str1.size()!=10){
      this->result_err = ERR_STRING_LEN;
      return;
    }


    this->device_type = data_str1.substr(4,4);

    if(this->device_type=="2018" && (data_str2.size()!=6 && data_str2.size()!=8)){
      this->result_err = ERR_STRING_LEN;
      return;
    }
    
    if(this->device_type!="2018"&&data_str2.size()!=8){
      this->result_err = ERR_STRING_LEN;
      return;
    }


    string sub_id_str;
    string roomId_str;
    string dev_rfssid_str;
    string dev_battery_str;
    string dev_status_4_6;
    string dev_status_6_8;
    dev_rfssid_str = data_str2.substr(0,2);
    dev_battery_str= data_str2.substr(2,2);
    dev_status_4_6 = data_str2.substr(4,2);
    dev_status_6_8 = data_str2.substr(6,2);

    int dev_battery = StrToDemicalData(dev_battery_str);
    if(dev_battery>=128){
      this->isAc = 1;
      dev_battery = dev_battery - 128;
    }else{
      this->isAc = 0;
    }

    sub_id_str = data_str1.substr(0,4);

    int sub_id = StrToDemicalData(sub_id_str);   
    roomId_str = data_str1.substr(8,2);
    int roomId = StrToDemicalData(roomId_str);   
    this->result_err = ERR_OK;
    this->device_status = DEVICE_OFFLINE;
    this->battery = dev_battery;
    this->rssid = StrToDemicalData(dev_rfssid_str);
    this->roomId = roomId;
    this->subId = sub_id;

    if(sub_id==0){
        // gateway status
        if(data_str2 == "00000000"){
            this->device_status = GATEWAY_AC_OFF;
        }else if(data_str2 == "00000001"){
            this->device_status = GATEWAY_AC_ON;
        }else if(data_str2 == "00000002"){
            this->device_status = GATEWAY_BATTERY_NORMAL;
        }else if(data_str2 == "00000003"){
            this->device_status = GATEWAY_BATTERY_LOW;
        }else if(data_str2 == "00000004"){
            this->device_status = GATEWAY_LONG_TIME_NO_MOVE;
        }else{
            this->device_status = GATEWAY_OFF_LINE;
        }
    } else {
        //door
        if(this->device_type == "0101"||this->device_type == "1101"||this->device_type == "010A"){
            if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_DOOR_OPEN;
            }else if(dev_status_4_6 == "A0"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "66"){
                this->device_status = DEVICE_DOOR_STILL_OPEN;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_DOOR_CLOSE;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
         //soskey
        else if(this->device_type == "0300"||this->device_type == "1300"||this->device_type == "2300"){
            if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_HELP;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //pir
        else if(this->device_type == "0100"||this->device_type == "1100"||this->device_type == "2100"||this->device_type == "0109"){
            if(dev_status_4_6 == "55"||dev_status_4_6 == "51"||dev_status_4_6 == "52"){
                this->device_status = DEVICE_HAS_PEOPLE_MOVE;
            }else if(dev_status_4_6 == "A0"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //smalarm
        else if(this->device_type == "0001"||this->device_type == "1001"||this->device_type == "2001"||this->device_type == "0009"||this->device_type == "1009"||this->device_type == "2009"||this->device_type == "000F"||this->device_type == "100F"||this->device_type == "200F"||this->device_type == "0020"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                if(this->device_type=="0020"){
                    this->device_status = DEVICE_ALARM;
                }else
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "14"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "12"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //coalarm
        else if(this->device_type == "0000"||this->device_type == "1000"||this->device_type == "2000"||this->device_type == "0008"||this->device_type == "1008"||this->device_type == "2008"||this->device_type == "000E"||this->device_type == "100E"||this->device_type == "200E"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55" || dev_status_4_6 == "21"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11" || dev_status_4_6 == "24"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "22"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "AA" || dev_status_4_6 == "20"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //co2alarm 
        else if(this->device_type == "0019"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "50"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //wateralarm
        else if(this->device_type == "0004"||this->device_type == "1004"||this->device_type == "2004"||this->device_type == "000C"||this->device_type == "100C"||this->device_type == "200C"||this->device_type == "0012"||this->device_type == "1012"||this->device_type == "2012"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //temp humidity sensor gs240
        else if(this->device_type == "0102"||this->device_type == "1102"||this->device_type == "2102"){
            if(dev_status_4_6 == "FF" || dev_status_4_6 == "FE"){
                this->device_status = DEVICE_OFFLINE;
            }else{

                int temp_buf =  StrToDemicalData(dev_status_4_6);
                int hum_buf  =  StrToDemicalData(dev_status_6_8);
                if(temp_buf>=128){
                    temp_buf = temp_buf - 256;
                }

                if(temp_buf>100||temp_buf<-40||hum_buf>100||hum_buf<0){
                    this->device_status = DEVICE_OFFLINE;
                    this->result_err = ERR_DATA_RANGE;
                }else {
                    if(dev_battery<=15){
                        this->device_status = DEVICE_LOW_BATTERY;
                    }else{
                        this->device_status = DEVICE_NORMAL;
                        this->gs240_Status = (GS240_Status*)malloc(sizeof(GS240_Status));
                        this->gs240_Status->cur_temp = temp_buf;
                        this->gs240_Status->cur_humidity = hum_buf;
                    }
                }
                    
            }
        }
        //cxsmalarm (GS559+GS592)
        else if(this->device_type == "0005"||this->device_type == "1109"||this->device_type == "2109"||this->device_type == "000D"||this->device_type == "100D"||this->device_type == "200D"||this->device_type == "0013"||this->device_type == "1013"||this->device_type == "2013"||this->device_type == "001A"||this->device_type == "0022"){
            if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_SMOKE_ALARM;
            }else if(dev_status_4_6 == "12"){
                this->device_status = DEVICE_SMOKE_SILENCE;
            }else if(dev_status_4_6 == "14"){
                this->device_status = DEVICE_SMOKE_FAULT;
            }else if(dev_status_4_6 == "BB"||dev_status_4_6 == "17"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "18"){
                this->device_status = DEVICE_TEMP_ALARM;
            }else if(dev_status_4_6 == "19"){
                this->device_status = DEVICE_SMOKE_ALARM;
            }else if(dev_status_4_6 == "12"){
                if(this->device_type=="0022"){
                    this->device_status = DEVICE_SILENCE;
                }else
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "15"||dev_status_4_6 == "1B"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "AA"||dev_status_4_6 == "10"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }

        }
        //gas alarm
        else if(this->device_type == "0002"||this->device_type == "1002"||this->device_type == "2002"||this->device_type == "1006"||this->device_type == "000A"||this->device_type == "100A"||this->device_type == "200A"||this->device_type == "0010"||this->device_type == "1010"||this->device_type == "2010"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //gas alarm (can check dismantle)
        else if(this->device_type == "1015"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "1C"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //new gas alarm
        else if(this->device_type == "0017"||this->device_type == "1017"||this->device_type == "2017"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"||dev_status_4_6 == "56"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "50"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "CC"){
                this->device_status = DEVICE_LIFE_STOP;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
           int gas_buf = StrToDemicalData(dev_status_6_8);
           this->gs870_Status = (GS870_Status *)malloc(sizeof(GS870_Status));
           this->gs870_Status->gas_concentration_half = ((gas_buf&0x80)==0?0:1);
           gas_buf =(gas_buf&0x7F);
           if(gas_buf>100){
               gas_buf = 100;
           }else if(gas_buf<5){
               gas_buf = 0;
           }
           this->gs870_Status->gas_concentration = gas_buf;
        }        
        //thermalalarm
        else if(this->device_type == "0003"||this->device_type == "1003"||this->device_type == "2003"||this->device_type == "000B"||this->device_type == "100B"||this->device_type == "200B"||this->device_type == "0011"||this->device_type == "1011"||this->device_type == "2011"||this->device_type == "0021"){
            if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "41"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "44"){
                this->device_status = DEVICE_FAULT;
            }else if(dev_status_4_6 == "42"){
                this->device_status = DEVICE_SILENCE;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //mode button
        else if(this->device_type == "0305"){
            if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }else if(dev_status_4_6 == "AA"||dev_status_4_6 == "01"||dev_status_4_6 == "02"||dev_status_4_6 == "04"||dev_status_4_6 == "08"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else if(dev_status_4_6 == "01"){
                    this->device_status = DEVICE_GS584_HOME_MODE_TRIGGER;
                }else if(dev_status_4_6 == "02"){
                    this->device_status = DEVICE_GS584_AWAY_MODE_TRIGGER;
                }else if(dev_status_4_6 == "04"){
                    this->device_status = DEVICE_GS584_SLEEP_MODE_TRIGGER;
                }else{
                    this->device_status = DEVICE_GS584_OTHER_MODE_TRIGGER;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //lock 0200
        else if(this->device_type == "1213"){
            if(dev_status_4_6 == "50" || dev_status_4_6 == "55"){
                this->device_status = DEVICE_UNLOCK;
            }else if(dev_status_4_6 == "51"){
                this->device_status = DEVICE_PASSWORD_UNLOCK;
            }else if(dev_status_4_6 == "52"){
                this->device_status = DEVICE_CARD_UNLOCK;
            }else if(dev_status_4_6 == "53"){
                this->device_status = DEVICE_FOOTPRINT_UNLOCK;
            }else if(dev_status_4_6 == "10"){
                this->device_status = DEVICE_ILLEGAL_OPERATION;
            }else if(dev_status_4_6 == "20"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "30"){
                this->device_status = DEVICE_COERCION;
            }else if(dev_status_4_6 == "40"){
                this->device_status = DEVICE_LOW_BATTERY;
            }else if(dev_status_4_6 == "AB"){
                this->device_status = DEVICE_ACTIVED;
            }else if(dev_status_4_6 == "56"){
                this->device_status = DEVICE_PASSWORD_ERROR;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //socket and new-socket and lamp_model 1216
        else if(this->device_type == "0200"||this->device_type == "1200"||this->device_type == "2200"||this->device_type == "1218"||this->device_type == "12160"){
            if(dev_status_4_6 == "FF"){
                this->device_status = DEVICE_OFFLINE;
            }else{
                if(dev_status_6_8 == "01"){
                    this->device_status = DEVICE_SOCKET_OPEN;
                }else if(dev_status_6_8 == "00"){
                    this->device_status = DEVICE_SOCKET_CLOSE;
                }else{
                    this->device_status = DEVICE_OFFLINE;
                }

            }
        }
        //button
        else if(this->device_type == "0301"||this->device_type == "1301"||this->device_type == "2301"){
            if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else if(dev_status_4_6 == "BB"||dev_status_4_6 == "01"){
                this->device_status = DEVICE_GS585_TRIGGER;
            }else
                this->device_status = DEVICE_OFFLINE;
        }
        //outdoor_siren 
        else if(this->device_type == "020E"||this->device_type == "120E"||this->device_type == "220E"){
            if(dev_status_4_6 == "A0"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "A1"){
                this->device_status = DEVICE_LOW_BATTERY;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //co_and_gas_alarmer 1014
        else if(this->device_type == "1014"){
            if(dev_status_4_6 == "11"){
                this->device_status = DEVICE_CO_SENSOR_FAULT;
            }else if(dev_status_4_6 == "12"){
                this->device_status = DEVICE_GAS_SENSOR_FAULT;
            }else if(dev_status_4_6 == "17"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "18"){
                this->device_status = DEVICE_CO_ALARM;
            }else if(dev_status_4_6 == "19"){
                this->device_status = DEVICE_GAS_ALARM;
            }else if(dev_status_4_6 == "1A"){
                this->device_status = DEVICE_CO_SILENCE;
            }else if(dev_status_4_6 == "1B"){
                this->device_status = DEVICE_GAS_SILENCE;
            }else if(dev_status_4_6 == "1C"){
                this->device_status = DEVICE_HAS_BEEN_MOVED;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //manipulator
        else if(this->device_type == "1208"){
            if(dev_status_4_6 == "00"){
                this->device_status = DEVICE_STOP_TURN;
            }else if(dev_status_4_6 == "01"||dev_status_4_6 == "03"){
                this->device_status = DEVICE_SOCKET_OPEN;
            }else if(dev_status_4_6 == "02"||dev_status_4_6 == "04"){
                this->device_status = DEVICE_SOCKET_CLOSE;
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //solenoid_valve_controller
        else if(this->device_type == "1217"){
            if(dev_status_4_6 == "00"){
                this->device_status = DEVICE_STOP_TURN;
            }else if(dev_status_4_6 == "01"){
                this->device_status = DEVICE_SOCKET_OPEN;
            }else if(dev_status_4_6 == "02"){
                this->device_status = DEVICE_SOCKET_CLOSE;
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //vibration_flash_compound_alarm
        else if(this->device_type == "0212"){
            if(dev_status_4_6 == "55"){
                this->device_status = DEVICE_ALARM;
            }if(dev_status_4_6 == "BB"){
                this->device_status = DEVICE_TEST_ALARM;
            }else if(dev_status_4_6 == "AA"){
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
            }else {
                this->device_status = DEVICE_OFFLINE;
            }
        }
        //co2_detector 
        else if(this->device_type == "2018"){
            if(data_str2.size()==8){
                if(dev_status_4_6 == "BB"){
                    this->device_status = DEVICE_TEST_ALARM;
                }else if(dev_status_4_6 == "55"){
                    this->device_status = DEVICE_ALARM;
                }else if(dev_status_4_6 == "11"){
                    this->device_status = DEVICE_FAULT;
                }else if(dev_status_4_6 == "12"){
                    this->device_status = DEVICE_PRE_HEAT;
                }else if(dev_status_4_6 == "50"){
                    this->device_status = DEVICE_SILENCE;
                }else if(dev_status_4_6 == "AA"){
                    if(dev_battery<=15){
                        this->device_status = DEVICE_LOW_BATTERY;
                    }else {
                        this->device_status = DEVICE_NORMAL;
                    }
                }else {
                    this->device_status = DEVICE_OFFLINE;
                }
            }else{
                this->gs241_Status = (GS241_Status *)malloc(sizeof(GS241_Status));
               if(dev_rfssid_str=="00"){
                 this->gs241_Status->message_type = 1;
                 string dea = data_str2.substr(2,4);
                 int temp_buf = StrToDemicalData(dea);
                if(temp_buf<0){
                    temp_buf =0;
                }else if(temp_buf>1000){
                    temp_buf = 1000;
                }
                
                this->gs241_Status->cur_temp_xiaoshu = temp_buf%10;
                this->gs241_Status->cur_temp_zheng = (temp_buf -300)/10;               

               }else if(dev_rfssid_str=="04"){
                 this->gs241_Status->message_type = 2;
                 string dea = data_str2.substr(2,4);
                 int hum_buf = StrToDemicalData(dea);
                if(hum_buf<0){
                    hum_buf = 0;
                }else if(hum_buf>999){
                    hum_buf = 999;
                }

                this->gs241_Status->cur_humidity_xiaoshu = hum_buf%10;
                this->gs241_Status->cur_humidity_zheng =hum_buf/10;             

                }else{
                 this->gs241_Status->message_type = 3;
                 string dea = data_str2.substr(2,4);
                 int con_buf = StrToDemicalData(dea);
                if(con_buf<400){
                    con_buf = 400;
                }else if(con_buf>5000){
                    con_buf = 5000;
                }
                this->gs241_Status->cur_co_concentration = con_buf;
               }
            }
        }
        //temp_controler
        else if(this->device_type == "0215"||this->device_type == "1215"||this->device_type == "2215"){
            if (dev_status_4_6=="FF" || dev_status_4_6=="FE") {
                this->device_status = DEVICE_OFFLINE;
            } else {
                if(dev_battery<=15){
                    this->device_status = DEVICE_LOW_BATTERY;
                }else {
                    this->device_status = DEVICE_NORMAL;
                }
                
                int ds = StrToDemicalData(dev_status_4_6);
                int ds2 = StrToDemicalData(dev_status_6_8);

                int shineng_window2 = (0x80) & this->rssid;
                int shineng_valve2 = (0x40) & this->rssid;
                int shishi_temp2= (0x3F) & (ds2>>2);
                int mode2 = (0x03) & (ds2);
                int status_window2 = (0x80) & ds;
                int status_valve2 = (0x40) & ds;
                int status_tongsuo = (0x20) & this->rssid;
                int xiaoshu = (0x20) & ds;
                int sta =  ((0x1F) & ds);
                this->gs361_Status = (GS361_Status *)malloc(sizeof(GS361_Status));
                this->gs361_Status->cur_set_temp = sta;
                this->gs361_Status->cur_set_temp_half = (xiaoshu==0?0:1);
                this->gs361_Status->cur_temp = shishi_temp2;
                this->gs361_Status->mode = mode2;
                this->gs361_Status->isWindowCheckEnable = (shineng_window2==0?0:1);
                this->gs361_Status->isWindowCheck = (status_window2==0?0:1);
                this->gs361_Status->isValveCheckEnable = (shineng_valve2==0?0:1);
                this->gs361_Status->isValveCheck = (status_valve2==0?0:1);
                this->gs361_Status->isChildLock = (status_tongsuo==0?0:1);
            }
        }
    }

}